{extend name="public/base" /}
    {block name="css"}
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="__ADMINLTE__plugins/iCheck/all.css">
    {/block}
  {block name="content"}
    
      <!-- Content Header (Page header) -->
        <section class="content-header">
          <!--<h1>-->
            <!--网站设置-->
            <!--<small>Option</small>-->
          <!--</h1>-->
          <div class="row">
            <div class="col-xs-12">
              <div class="addtabs">
                  {foreach $list as $key=>$vo}
                  <a id="{$vo.flag}" href="javascript:;" class="tag btn btn-primary">{$vo.name}</a>
                  {/foreach}
              </div>
        </div>
    </div>
</section>

<!-- Main content -->
<section class="content">
        {foreach $list as $key => $vo}
        <div class="row page" id="page-{$vo.flag}"{if ($vo.flag!=$flag)} style="display:none;"{/if}>
            {if (APP_DEVEL)}
            <div class="col-md-9">
            {else /}
            <div class="col-md-12">
                {/if}
                <div class="box box-default">
                    <div class="box-header with-border">
                        <h3 class="box-title">{$vo['name']}</h3>

                        <div class="box-tools pull-right">
                            <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                            <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form role="form" action="{:U('Option/edit',['id'=>$vo['id']])}" method="post">
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <table class="table table-bordered">
                                        {foreach $vo['form'] as $name=>$va}
                                        <tr>
                                            <th width="140">{$name}:</th>
                                            <td>{$va}</td>
                                        </tr>
                                        {/foreach}
                                    </table>
                                </div>
                                <!-- /.col -->
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-primary">确认修改</button>
                        </div>
                    </form>
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->

            {if (APP_DEVEL)}
            <div class="col-md-3">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">配置项设置</h3>

                        <div class="box-tools pull-right">
                            <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                            <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tr>
                                <th>配置标识</th>
                                <th>配置项名</th>
                                <th>配置类型</th>
                                <th>操作</th>
                            </tr>
                            {foreach $vo['item'] as $tag => $va}
                            <tr>
                                <td>{$tag}</td>
                                <td>{$va.tag_name}</td>
                                <td>{$va.tag_type}</td>
                                <td>
                                    <div class="btn-group">
                                        <button type="button"
                                                onclick="jump('{:U('Option/delItem',['id'=>$vo['id'], 'tag'=>$tag])}')"
                                                class="btn btn-xs btn-danger">删除
                                        </button>
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button style="width: 120px" class="btn btn-sm btn-success pull-left wh-addTags">添加配置项</button>
                        <button style="width: 120px" onclick="jump('{:U('Option/del', ['id'=>$vo['id']])}')"
                                class="btn btn-sm btn-danger pull-right">删除配置组
                        </button>
                    </div>
                </div>
                <!-- /.box -->
                <div class="box" style="display:none">
                    <div class="box-header">
                        <h3 class="box-title">添加配置项</h3>

                        <div class="box-tools pull-right">
                            <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                            <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <form role="form" action="{:U('Option/addItem', ['id'=>$vo['id']])}" method="post">
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tr>
                                    <th>配置标识</th>
                                    <td><input class="form-control input-sm" type="text" placeholder="" name="tag"></td>
                                </tr>
                                <tr>
                                    <th>配置项名</th>
                                    <td><input class="form-control input-sm" type="text" placeholder="" name="name">
                                    </td>
                                </tr>
                                <tr>
                                    <th>配置类型</th>
                                    <td><input class="form-control input-sm" type="text" placeholder="" name="type">
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-primary">确认添加</button>
                        </div>
                    </form>
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
            {/if}
        </div>
        <!-- /.row -->
        {/foreach}
        {if (APP_DEVEL)}
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <form role="form" action="{:U('Option/add')}" method="post">
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tr>
                                    <td><input class="form-control input-lg" type="text" placeholder="配置组名" name="name">
                                    </td>
                                    <td><input class="form-control input-lg" type="text" placeholder="配置组标识"
                                               name="flag"></td>
                                    <td>
                                        <button type="submit" class="btn btn-lg btn-primary">添加配置组</button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </form>
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
        {/if}
    </div>

</section>
<!-- Main content END-->

{/block}
{block name="script"}
    <!-- iCheck 1.0.1 -->
    <script src="__ADMINLTE__plugins/iCheck/icheck.min.js"></script>
    <script>
        $('.tag').click(function(){
            var page = $(this).attr('id');
            $('.page').hide();
            $('#page-'+page).show();
        });
        var jump = function(url){
            window.location.href = url;
        }
        $(".wh-addTags").click(function(){
            $(this).parents(".box").next().slideDown();
        });
        //iCheck for checkbox and radio inputs
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
          checkboxClass: 'icheckbox_minimal-blue',
          radioClass: 'iradio_minimal-blue'
        });
    </script>
{/block}

